import { strategicManage } from '~/config/server'
import { NetService } from '~/utils/net.service';
import { Inject, Debounce } from '~/core/decorator';
import { Service } from '~/core/service';

export class EntityIdService extends Service {
  @Inject(NetService)
  private netService: NetService;

  /**
   * 获取支持的实体ID策略字段
   */
  @Debounce()
  public getEntityFields () {
    return this.netService.send({
      server: strategicManage.entityIdController.getEntityFields,
    });
  }
  /**
   * 查询全部实体ID
   */
  @Debounce()
  public getEntityId (data, page) {
    return this.netService.send({
      server: strategicManage.entityIdController.getEntityIdStrategyConfigList,
      data,
      page,
    });
  }

  /**
   * 编辑实体ID
   */
  @Debounce()
  public findEntityId (data) {
    return this.netService.send({
      server: strategicManage.entityIdController.findEntityIdStrategyConfigById,
      data,
      loading: true
    });
  }

  /**
   * 保存实体ID
   */
  @Debounce()
  public saveEntityId (data) {
    return this.netService.send({
      server: strategicManage.entityIdController.saveEntityIdStrategyConfig,
      data,
      loading: true
    });
  }

  /**
   * 启用/停用实体ID
   */
  @Debounce()
  public updateEntityId (data, page) {
    return this.netService.send({
      server: strategicManage.entityIdController.updateEntityIdStrategyConfigState,
      data,
      page,
      loading: true
    });
  }

  /**
   * 删除实体ID
   */
  @Debounce()
  public deleteEntityId (data) {
    return this.netService.send({
      server: strategicManage.entityIdController.deleteEntityIdStrategyConfigById,
      data,
      loading: true,
    });
  }

  /**
   * 查询实体ID修改日志
   */
  @Debounce()
  public logEntityId (data, page?) {
    return this.netService.send({
      server: strategicManage.entityIdController.getEntityIdStrategyConfigLogList,
      data,
      loading: true,
      page
    });
  }

  /**
   * 查询实体ID审批记录
   */
  @Debounce()
  public findEntityIdHistory (data) {
    return this.netService.send({
      server: strategicManage.entityIdController.findEntityIdStrategyConfigRecordHistory,
      data,
      loading: true,
    });
  }

  /**
   * 查询一条实体ID
   */
  public getTagApplyById (data) {
    return this.netService.send({
      server: strategicManage.entityIdController.findEntityIdStrategyConfigLogById,
      data,
      loading: true,
    });
  }
}
